using System;
using System.Data;
using System.Xml;

using OR.Reuse.Persistence;

using Derived = OR.Lazarus.Business.Entities.Manifest;

namespace OR.Lazarus.Business.Entities.Manifest.Lazarus
{
	/// <summary>
	/// 
	/// </summary>
   public class FileDetail : EntityBase
   {
		protected System.String mName;
		protected string mRelativePath;
		protected string mType;
		protected System.Int32 mSize;
		protected string mConceptName;
		protected string mDescription;

		public FileDetail()
		{
	
		}
	
		/// <summary>
		/// 
		/// </summary>
		public System.String Name
		{
			get
			{
				return ( mName );
			}
			set
			{
				mName = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string RelativePath
		{
			get
			{
				return ( mRelativePath );
			}
			set
			{
				mRelativePath = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string Type
		{
			get
			{
				return ( mType );
			}
			set
			{
				mType = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public System.Int32 Size
		{
			get
			{
				return ( mSize );
			}
			set
			{
				mSize = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string ConceptName
		{
			get
			{
				return ( mConceptName );
			}
			set
			{
				mConceptName = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string Description
		{
			get
			{
				return ( mDescription );
			}
			set
			{
				mDescription = value;
			}
		}

		public override void LoadXml( XmlElement pSource )
		{
			// Scalar Values
			mName = DataUtility.GetString( pSource, "name" );
			mRelativePath = DataUtility.GetString( pSource, "relative-path" );
			mType = DataUtility.GetString( pSource, "type" );
			mSize = DataUtility.GetInt32( pSource, "size", 0 );
			mConceptName = DataUtility.GetString( pSource, "concept-name" );
			XmlElement vDescription = ( XmlElement )pSource.SelectSingleNode( "lm:description", PersistenceConfig.Namespaces );
			
			if ( vDescription != null )
			{
				mDescription = vDescription.InnerText;
			}
			
		}
		
		public override XmlElement SaveXml( XmlDocument p_docContext )
		{
			XmlElement vNewElement	= p_docContext.CreateElement( "lm", "file", "http://schemas.icitadel.com/Lazarus/Manifest.xsd" );

			// Scalar Values
			if ( !String.IsNullOrEmpty( mName ) )
			{
				vNewElement.SetAttribute( "name", mName );
			}
					
			if ( !String.IsNullOrEmpty( mRelativePath ) )
			{
				vNewElement.SetAttribute( "relative-path", mRelativePath );
			}
					
			if ( !String.IsNullOrEmpty( mType ) )
			{
				vNewElement.SetAttribute( "type", mType );
			}
					
			vNewElement.SetAttribute( "size", mSize.ToString() );
			if ( !String.IsNullOrEmpty( mConceptName ) )
			{
				vNewElement.SetAttribute( "concept-name", mConceptName );
			}
					
			if ( !String.IsNullOrEmpty( mDescription ) )
			{
				XmlElement	vDescription = p_docContext.CreateElement( "lm", "description", "http://schemas.icitadel.com/Lazarus/Manifest.xsd" );
				vDescription.InnerText = mDescription;
				vNewElement.AppendChild( vDescription );
			}
					

			return ( vNewElement );
		}

		public virtual object Clone()
		{
			Derived.FileDetail v_oReturn = new Derived.FileDetail();
			
			v_oReturn.Name = mName;
			v_oReturn.RelativePath = mRelativePath;
			v_oReturn.Type = mType;
			v_oReturn.Size = mSize;
			v_oReturn.ConceptName = mConceptName;
			v_oReturn.Description = mDescription;
			
			// FK Values

			// Collections
			
			return ( v_oReturn );
		}

		public virtual Derived.FileDetail CloneTyped()
		{
			return ( ( Derived.FileDetail )this.Clone() );
		}
   }
}
   